﻿Option Explicit On
Option Strict On

Partial Class contactus
    Inherits System.Web.UI.Page

    Protected Sub SendBtn_Click(sender As Object, e As System.EventArgs) Handles SendBtn.Click
        'Page.Validate()
        'If Page.IsValid Then
        lblResult.Text = "+"
        lblResult.ForeColor = Drawing.Color.Green

        'User does not need to be authenticated to use this form
        'If User.Identity.IsAuthenticated Then
        Dim msgReplyUserName = User.Identity.Name
        Dim msgFrom = NameTxtBox.Text
        Dim msgReplyEmail = EmailTxtBox.Text
        Dim msgSubject = SubjectTxtBox.Text
        Dim msgContent = QuestionTxtBox.Text
        Dim msgRcvdDate As New DateTime()
        msgRcvdDate = DateTime.Now

        Dim contactUsTA As New LogginsLogDSTableAdapters.SPTableAdapter
        contactUsTA.usp_ContactUsPageInsert(Server.HtmlEncode(msgFrom), Server.HtmlEncode(msgReplyEmail), Server.HtmlEncode(msgReplyUserName), Server.HtmlEncode(msgSubject), Server.HtmlEncode(msgContent), String.Empty, msgRcvdDate)



        MessageLbl.Text = "Your message has been sent successfuly!"

        Dim sendemail As New SendEmailViaGoogle()
        Dim mails As String = ConfigurationManager.AppSettings("sitecontactemail").ToString()

        Try
            sendemail.SendEmail(mails, mails, "New Contact Us Message: " + msgSubject, msgContent)
            NameTxtBox.Text = ""
            EmailTxtBox.Text = ""
            SubjectTxtBox.Text = ""
            QuestionTxtBox.Text = ""
        Catch ex As Exception

        End Try
        'Else : Response.Redirect("~/Account/Login.aspx")

        'End If
        'Else
        'lblResult.Text = "-"
        'lblResult.ForeColor = Drawing.Color.Red
        'End If

    End Sub

    Protected Sub CancelBtn_Click(sender As Object, e As System.EventArgs) Handles CancelBtn.Click
        NameTxtBox.Text = ""
        EmailTxtBox.Text = ""
        SubjectTxtBox.Text = ""
        QuestionTxtBox.Text = ""
        MessageLbl.Text = ""
    End Sub
End Class
